package com.hbnu.iostream;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
 * @author kittychen
 * @date 2025-09-30 17:11
 */
public class ReaderDemo02 {

    public static void main(String[] args) {
        String path = "E:" + File.separator + "2309" + File.separator + "writer.txt";

        File file = new File(path);

        Reader reader = null;

        try {
            reader = new FileReader(file);

            char[] cbuf = new char[1024];

            int len = 0;
            int temp = 0;
            while ((temp = reader.read()) != -1) {
                cbuf[len++] = (char) temp;
            }

            System.out.println(new String(cbuf, 0, len));
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // try {
            //     if (reader != null) {
            //         reader.close();
            //     }
            // } catch (IOException e) {
            //     e.printStackTrace();
            // }
        }
    }
}
